Passed
Push — main ( 1ee933...792997 )
by Andrii
02:37
created

expect-to-same-render.ts ➔ expectRender   A

Complexity

Conditions 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
c 0
b 0
f 0
rs 10
cc 1
1
import {renderToStaticMarkup} from "react-dom/server"
2
3
type RElement = Parameters<typeof renderToStaticMarkup>[0]
4
5
export default expectRender
6
7
function expectRender(
8
  ...elements: RElement[]
9
) {
10
  return {
11
    toSame: (...expectations: RElement[]) => 
12
      expect(
13
        elements.map(renderToStaticMarkup).join("")
14
      ).toBe(
15
        expectations.map(renderToStaticMarkup).join("")
16
      )
17
  }
18
}
19